﻿#include"XQPushReply.h"
#include"XQHttpHeadRequest.h"
#include"XQLog.hpp"
#include"XQMySql.hpp"
#include"XQPush.h"
#include"XQAccountData.h"
#include"XQAlgorithm.h"
#include"XQMail.h"
#include<QTcpSocket>
using namespace XQPush;
XQPushReply::XQPushReply(QObject* parent)
	:XQHttpReplyObject(parent)
{
}

void XQPushReply::setAccountManagement(XQHttpReplyAccount* account)
{
	m_account = account;
}


void XQPushReply::setAppMysql(XQMySql* mysql)
{
	m_appMysql = mysql;
}

void XQPushReply::setMail(XQMail* mail)
{
	m_mail = mail;
}

bool XQPushReply::isAccepted(XQHttpHeadObject* head) const
{
	//qDebug() << "判断是否接受";
	if (head == nullptr || head->header(Head::App) != name().toUtf8())
		return false;//判断请求头是否是这个app
	return false;
}

XQHttpHeadReply XQPushReply::reply(QIODevice* socket, XQHttpHeadRequest* header)
{
	if (socket == nullptr || header == nullptr)
		return XQHttpHeadReply();
	QTcpSocket* Socket = static_cast<QTcpSocket*>(socket);
	auto Command = header->header("Command");
	auto Type= header->header("Type");
	if (Command == "")
	{
		auto json = QJsonDocument::fromJson(header->content());
		
	}
	return XQHttpHeadReply();
}

void XQPushReply::buffer(QIODevice* socket, XQHttpHeadObject* head, const QByteArray& buffer)
{
	XQHttpReplyObject::buffer(socket,head,buffer);
}

